<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>银行信息采集</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div id="ligergrid1" class="sq-grid">
        <div id="pageInTab" class="pageInTab">
            <form id="ins_cfg_info_edit_form">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="caption">
                        <span class="title">账户信息</span>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">机构名称</div>
                        <div class="field">
                            <span>${fundRasInsNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">企业名称</div>
                        <div class="field">
                            <span>${cstNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">证件类型</div>
                        <div class="field">
                            <span>${certTypCdNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">证件号</div>
                        <div class="field">
                            <span>${certNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">法人姓名</div>
                        <div class="field">
                            <span>${mNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">身份证号</div>
                        <div class="field">
                            <span>${mCertNo}</span>
                        </div>
                    </div>
                    <c:if test="${certTypCd == 'b'}">
                        <div class="fieldBox col_33">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <span>${bcCertTypCdNm}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件编号</div>
                            <div class="field">
                                <span>${bcCertNo}</span>
                            </div>
                        </div>
                    </c:if>
                    <div class="fieldBox col_33">
                        <div class="label">开户银行</div>
                        <div class="field">
                            <span>中国建设银行</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">账户类型</div>
                        <div class="field">
                            <select name="accTypCd" id="accTypCd" data-value="" validate="{required:true, select: true}">
                                <option value="">--请选择--</option>
                                <option value="0100" <c:if test="${accTypCd == '0100'}">selected = "selected"</c:if>>对公账户</option>
                                <option value="0200" <c:if test="${accTypCd == '0200'}">selected = "selected"</c:if>>个人账户</option>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">银行卡号</div>
                        <div class="field">
                            <input name="accNo" id="accNo" type="text" class="ui-textbox" value="${accNo}"
                          validate="{number:true, maxlength:22, minlength:15}">
                        </div>
                    </div>

                    <div class="fieldBox col_100_auto">
                        <div id="hint" style="text-align: center">
                            <span style="color: #20099b">友情提示：该业务只支持绑定建行储蓄卡，该卡将作为还款卡使用；户名需要是企业名称或法人名称。</span>
                        </div>
                    </div>

                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                    <div class="field">
                        <input name="insCode" id="insCode" type="text" class="ui-textbox" value="${insCode}">
                        <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
                        <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
                        <input name="cstAccInfoId" id="cstAccInfoId" type="text" class="ui-textbox" value="${cstAccInfoId}">
                        <input name="fundRasInsId" id=fundRasInsId type="text" class="ui-textbox" value="${fundRasInsId}">
                    </div>
                    </div>
                </div>
                <c:if test="${isShowSaveBtn == '1'}">
                <div id="saveInsCfgDiv" class="btnsBox">
                        <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
                </div>
                </c:if>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        initData();
    });

    function initData() {
        $("#ins_cfg_info_edit_form").ligerForm({
            validate: true
        });
    }

    // 保存项目客户信息，后面弹出准入验证的资料确认页
    function saveInfo() {
        var ligerForm = liger.get("ins_cfg_info_edit_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        if(!$("#accNo").val()){
            top.$.ligerDialog.SQalert({content: "请填写银行账号！", SQ_type: "error"});
            return false;
        }
        if(!$("#accTypCd").val()){
            top.$.ligerDialog.SQalert({content: "请选择账户类型！", SQ_type: "error"});
            return false;
        }

        var data = ligerForm.getData();

        data["cstAccInfoId"] = '${cstAccInfoId}';
        data["prjId"] = $("#prjId").val();//项目id
        data["cstId"] = $("#cstId").val();//客户id
        data["insCode"] = $("#insCode").val();//机构code
        data["fundRasInsId"] = $("#fundRasInsId").val();//机构

        data["mCertNo"] = '${mCertNo}';//法人身份证号
        data["accNo"] =  $("#accNo").val();//银行账号
        data["mNm"] = '${mNm}';//法人名称
        data["accTypCd"] = $("#accTypCd").val();//账户类型

        var url = '<%=path%>/institution/ccbanktb/savePrjCstAccInfo.do';
        var wait_dialog;
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    UIUtils.alertSuccessHold1(msg.info);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }
</script>
</body>
</html>